home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games Extra 1996 September / Amiga Games Extra CD-ROM 9-1996.iso / userbox / publicdomain / vim-4.2 / src / globals.h < prev    next >
C/C++ Source or Header  |  1996-06-09  |  18KB  |  445 lines

  1. /* vi:set ts=4 sw=4:
  2.  *
  3.  * VIM - Vi IMproved        by Bram Moolenaar
  4.  *
  5.  * Do ":help uganda"  in Vim to read copying and usage conditions.
  6.  * Do ":help credits" in Vim to see a list of people who contributed.
  7.  */
  8.  
  9. /*
  10.  * definition of global variables
  11.  *
  12.  * EXTERN is only defined in main.c (and in option.h)
  13.  */
  14.  
  15. #ifndef EXTERN
  16. # define EXTERN extern
  17. # define INIT(x)
  18. #else
  19. # ifndef INIT
  20. #  define INIT(x) x
  21. # endif
  22. #endif
  23.  
  24. /*
  25.  * Number of Rows and Columns in the screen.
  26.  * Must be long to be able to use them as options in option.c.
  27.  */
  28. EXTERN long        Rows;                    /* number of rows in the screen */
  29. EXTERN long        Columns;                /* number of columns in the screen */
  30.  
  31. /*
  32.  * The characters that are currently on the screen are kept in NextScreen.
  33.  * It is a single block of characters, twice the size of the screen.
  34.  * First come the characters for one line, then the attributes for that line.
  35.  *
  36.  * "LinePointers[n]" points into NextScreen, at the start of line 'n'.
  37.  * "LinePointers[n] + Columns" points to the attibutes of line 'n'.
  38.  */
  39. EXTERN char_u     *NextScreen INIT(= NULL);
  40. EXTERN char_u     **LinePointers INIT(= NULL);
  41.  
  42. EXTERN int        screen_Rows INIT(= 0);        /* actual size of NextScreen */
  43. EXTERN int        screen_Columns INIT(= 0);    /* actual size of NextScreen */
  44.  
  45. /*
  46.  * Positioning the cursor is reduced by remembering the last position.
  47.  * Mostly used by screen_char().
  48.  */
  49. EXTERN int    screen_cur_row, screen_cur_col;        /* last known cursor position */
  50.  
  51. /*
  52.  * When vgetc() is called, it sets mod_mask to the set of modifiers that are
  53.  * held down based on the KSMOD_* symbols that are read first.
  54.  */
  55. EXTERN int        mod_mask INIT(= 0x0);            /* current key modifiers */
  56.  
  57. /*
  58.  * Cmdline_row is the row where the command line starts, just below the
  59.  * last window.
  60.  * When the cmdline gets longer than the available space the screen gets
  61.  * scrolled up. After a CTRL-D (show matches), after hitting ':' after
  62.  * "hit return", and for the :global command, the command line is
  63.  * temporarily moved. The old position is restored with the next call to
  64.  * updateScreen().
  65.  */
  66. EXTERN int        cmdline_row;
  67.  
  68. EXTERN int        redraw_cmdline INIT(= FALSE);    /* cmdline must be redrawn */
  69. EXTERN int        clear_cmdline INIT(= FALSE);    /* cmdline must be cleared */
  70. EXTERN int        modified INIT(= FALSE);            /* buffer was modified since
  71.                                                     last redraw */
  72. EXTERN int        screen_cleared INIT(= FALSE);    /* screen has been cleared */
  73.  
  74. /*
  75.  * When '$' is included in 'cpoptions' option set:
  76.  * When a change command is given that deletes only part of a line, a dollar
  77.  * is put at the end of the changed text. dollar_vcol is set to the virtual
  78.  * column of this '$'.
  79.  */
  80. EXTERN colnr_t    dollar_vcol INIT(= 0);
  81.  
  82. /*
  83.  * used for completion on the command line
  84.  */
  85. EXTERN int        expand_context INIT(= CONTEXT_UNKNOWN);
  86. EXTERN char_u    *expand_pattern INIT(= NULL);
  87. EXTERN int        expand_interactively INIT(= FALSE);
  88.  
  89. /*
  90.  * Functions for putting characters in the command line,
  91.  * while keeping NextScreen updated.
  92.  */
  93. EXTERN int        msg_col;
  94. EXTERN int        msg_row;
  95. EXTERN int        msg_scrolled; 
  96.  
  97. EXTERN char_u    *keep_msg INIT(= NULL);        /* msg to be shown after redraw */
  98. EXTERN int        keep_msg_highlight INIT(= 0);/* highlight for keep_msg */
  99. #ifdef SLEEP_IN_EMSG
  100. EXTERN int        need_sleep INIT(= FALSE);    /* call sleep() before redraw */
  101. #endif
  102. EXTERN int        need_fileinfo INIT(= FALSE);/* do fileinfo() after redraw */
  103. EXTERN int        msg_scroll INIT(= FALSE);    /* msg_start() will scroll */
  104. EXTERN int        msg_didout INIT(= FALSE);    /* msg_outstr() was used in line */
  105. EXTERN int        msg_didany INIT(= FALSE);    /* msg_outstr() was used at all */
  106. EXTERN int        emsg_off INIT(= FALSE);        /* don't display errors for now */
  107. EXTERN int        did_emsg;                    /* set by emsg() for DoOneCmd() */
  108. EXTERN int        emsg_on_display INIT(= FALSE);    /* there is an error message */
  109. EXTERN char_u    *sourcing_name INIT( = NULL);/* name of error message source */
  110. EXTERN linenr_t    sourcing_lnum INIT(= 0);    /* line number of the source file */
  111.  
  112. EXTERN int        msg_highlight INIT(= FALSE);/* message should be highlighted */
  113. EXTERN char_u    *highlight INIT(= NULL);    /* string for start of highlighting */
  114. EXTERN char_u    *unhighlight INIT(= NULL);    /* string for end of highlighting */
  115. EXTERN int        scroll_region INIT(= FALSE);/* terminal supports scroll region */
  116. EXTERN int        highlight_match INIT(= FALSE);    /* show search match pos */
  117. EXTERN int        search_match_len;            /* length of matched string */
  118. EXTERN int        no_smartcase INIT(= FALSE);    /* don't use 'smartcase' once */
  119. EXTERN int        need_check_timestamps INIT(= FALSE);    /* got STOP signal */
  120.  
  121. #ifdef AUTOCMD
  122. EXTERN int        autocmd_busy INIT(= FALSE);    /* Is apply_autocmds() busy? */
  123. #endif
  124.  
  125. #ifdef USE_MOUSE
  126. /*
  127.  * Mouse coordinates, set by check_termcode()
  128.  */
  129. EXTERN int        mouse_row;
  130. EXTERN int        mouse_col;
  131. EXTERN int        mouse_past_bottom INIT(= FALSE);/* mouse below last line */
  132. EXTERN int        mouse_past_eol INIT(= FALSE);    /* mouse right of line */
  133. #endif
  134.  
  135. #ifdef USE_GUI
  136. /*
  137.  * Menu item just selected, set by check_termcode()
  138.  */
  139. EXTERN GuiMenu    *current_menu;
  140.  
  141. /*
  142.  * Scrollbar moved and new value, set by check_termcode()
  143.  */
  144. EXTERN int        current_scrollbar;
  145. EXTERN long_u    scrollbar_value;
  146. #endif
  147.  
  148. /*
  149.  * All windows are linked in a list. firstwin points to the first entry, lastwin
  150.  * to the last entry (can be the same as firstwin) and curwin to the currently
  151.  * active window.
  152.  */
  153. EXTERN WIN        *firstwin;        /* first window */
  154. EXTERN WIN        *lastwin;        /* last window */
  155. EXTERN WIN        *curwin;        /* currently active window */
  156.  
  157. /*
  158.  * All buffers are linked in a list. 'firstbuf' points to the first entry,
  159.  * 'lastbuf' to the last entry and 'curbuf' to the currently active buffer.
  160.  */
  161. EXTERN BUF        *firstbuf INIT(= NULL);    /* first buffer */
  162. EXTERN BUF        *lastbuf INIT(= NULL);    /* last buffer */
  163. EXTERN BUF        *curbuf INIT(= NULL);    /* currently active buffer */
  164.  
  165. /*
  166.  * list of files being edited (argument list)
  167.  */
  168. EXTERN char_u    **arg_files;    /* list of files */
  169. EXTERN int        arg_count;         /* number of files */
  170. EXTERN int        arg_exp;        /* when TRUE arg_files must be freed */
  171. EXTERN int        arg_had_last INIT(= FALSE);    /* accessed last file in arglist */
  172.  
  173. EXTERN int        ru_col;            /* column for ruler */
  174. EXTERN int        sc_col;            /* column for shown command */
  175.  
  176. /*
  177.  * When starting or exiting some things are done differently (e.g. screen
  178.  * updating).
  179.  */
  180. EXTERN int        starting INIT(= TRUE);
  181.                                 /* set to FALSE when starting up finished */
  182. EXTERN int        exiting INIT(= FALSE);
  183.                                 /* set to TRUE when abandoning Vim */
  184. EXTERN int        full_screen INIT(= TRUE);
  185.                                 /* set to FALSE when not doing full-screen
  186.                                  * output and only writing some messages */
  187.  
  188. EXTERN int        secure INIT(= FALSE);
  189.                                 /* set to TRUE when only "safe" commands are 
  190.                                  * allowed, e.g. when sourcing .exrc or .vimrc
  191.                                  * in current directory */
  192.  
  193. EXTERN int        found_version INIT(= 0);
  194.                                 /* version nr found after :version command */
  195.  
  196. EXTERN FPOS     VIsual;         /* start position of Visual */
  197. EXTERN FPOS        VIsual_save;    /* copy of VIsual before 'v' command */
  198. EXTERN int        VIsual_active INIT(= FALSE);
  199.                                 /* wheter Visual mode is active */
  200. EXTERN FPOS     VIsual_end;        /* end position of Visual; set when
  201.                                     VIsual_active becomes FALSE */
  202.  
  203. EXTERN int        VIsual_mode INIT(= 'v');
  204.                                 /* type of Visual mode */
  205. EXTERN int        VIsual_mode_save;
  206.                                 /* copy of VIsual_mode before 'v' command */
  207. EXTERN int        redo_VIsual_busy INIT(= FALSE);
  208.                                 /* TRUE when redo-ing a visual */
  209.  
  210. #ifdef USE_MOUSE
  211. /*
  212.  * When pasting text with the middle mouse button in visual mode with
  213.  * restart_edit set, remember where it started so we can set Insstart.
  214.  */
  215. EXTERN FPOS        where_paste_started;
  216. #endif
  217.  
  218. /*
  219.  * This flag is used to make auto-indent work right on lines where only a
  220.  * <RETURN> or <ESC> is typed. It is set when an auto-indent is done, and
  221.  * reset when any other editting is done on the line. If an <ESC> or <RETURN>
  222.  * is received, and did_ai is TRUE, the line is truncated.
  223.  */
  224. EXTERN int       did_ai INIT(= FALSE);
  225.  
  226. /*
  227.  * This flag is set when a smart indent has been performed. When the next typed
  228.  * character is a '{' the inserted tab will be deleted again.
  229.  */
  230. EXTERN int        did_si INIT(= FALSE);
  231.  
  232. /*
  233.  * This flag is set after an auto indent. If the next typed character is a '}'
  234.  * one indent will be removed.
  235.  */
  236. EXTERN int        can_si INIT(= FALSE);
  237.  
  238. /*
  239.  * This flag is set after an "O" command. If the next typed character is a '{'
  240.  * one indent will be removed.
  241.  */
  242. EXTERN int        can_si_back INIT(= FALSE);
  243.  
  244. EXTERN int        old_indent INIT(= 0);    /* for ^^D command in insert mode */
  245.  
  246. EXTERN int        State INIT(= NORMAL);    /* This is the current state of the
  247.                                          * command interpreter. */
  248. EXTERN int        no_mapping INIT(= FALSE);    /* currently no mapping allowed */
  249. EXTERN int        allow_keys INIT(= FALSE);    /* allow key codes when no_mapping
  250.                                              * is set */
  251.  
  252. EXTERN int        restart_edit INIT(= 0);    /* call edit when next command finished
  253.                                          */
  254. EXTERN int        arrow_used;                /* Normally FALSE, set to TRUE after
  255.                                          * hitting cursor key in insert mode.
  256.                                          * Used by vgetorpeek() to decide when
  257.                                          * to call u_sync() */
  258. #ifdef INSERT_EXPAND
  259. EXTERN char_u    *edit_submode INIT(= NULL);    /* msg for CTRL-X submode */
  260. EXTERN char_u    *edit_submode_extra INIT(= NULL);/* extra info for msg */
  261. EXTERN int        edit_submode_highl;            /* extra info highlighted */
  262. EXTERN int        ctrl_x_mode INIT(= 0);    /* Which Ctrl-X mode are we in? */
  263. #endif
  264.  
  265. EXTERN int        Recording INIT(= FALSE);/* TRUE when recording into a register
  266.                                          */
  267. EXTERN int        Exec_reg INIT(= FALSE);    /* TRUE when executing a register */
  268.  
  269. EXTERN int        did_cd INIT(= FALSE);    /* TRUE when :cd dir used */
  270. EXTERN int        no_abbr INIT(= TRUE);    /* TRUE when no abbreviations loaded */
  271. EXTERN int        fo_do_comments INIT(= FALSE);
  272.                                         /* TRUE when comments are to be
  273.                                          * formatted */
  274. #if defined MSDOS  ||  defined WIN32
  275. EXTERN int        beep_count INIT(= 0);    /* nr of beeps since last char typed */
  276. #endif
  277.  
  278. EXTERN char_u     *IObuff;                /* sprintf's are done in this buffer */
  279. EXTERN char_u    *NameBuff;                /* file names are expanded in this
  280.                                          * buffer */
  281. EXTERN char_u    msg_buf[MSG_BUF_LEN];    /* small buffer for messages */
  282.  
  283. EXTERN int        RedrawingDisabled INIT(= FALSE);
  284.                                         /* Set to TRUE if doing :g */
  285.  
  286. EXTERN int        readonlymode INIT(= FALSE); /* Set to TRUE for "view" */
  287. EXTERN int        recoverymode INIT(= FALSE); /* Set to TRUE for "-r" option */
  288.  
  289. EXTERN char_u    *typebuf INIT(= NULL);    /* buffer for typed characters */
  290. EXTERN int        typebuflen;                /* size of typebuf */
  291. EXTERN int        typeoff;                /* current position in typebuf */
  292. EXTERN int        typelen;                /* number of valid chars in typebuf */
  293. EXTERN int        KeyTyped;                /* TRUE if user typed current char */
  294. EXTERN int        KeyStuffed;                /* TRUE if current char from stuffbuf */
  295.  
  296. EXTERN int        must_redraw INIT(= 0);        /* type of redraw necessary */
  297. EXTERN int        skip_redraw INIT(= FALSE);    /* skip redraw once */
  298. EXTERN int        do_redraw INIT(= FALSE);    /* extra redraw once */
  299.  
  300. EXTERN char_u    *use_viminfo INIT(= NULL);    /* name of viminfo file to use */
  301.  
  302. #define NSCRIPT 15
  303. EXTERN FILE     *scriptin[NSCRIPT];            /* streams to read script from */
  304. EXTERN int        curscript INIT(= 0);        /* index in scriptin[] */
  305. EXTERN FILE     *scriptout    INIT(= NULL);     /* stream to write script to */
  306.  
  307. EXTERN int        got_int INIT(= FALSE);        /* set to TRUE when interrupt
  308.                                                    signal occurred */
  309. EXTERN int        term_console INIT(= FALSE);    /* set to TRUE when consule used */
  310. EXTERN int        termcap_active INIT(= FALSE);    /* set by starttermcap() */
  311. EXTERN int        bangredo INIT(= FALSE);        /* set to TRUE whith ! command */
  312. EXTERN int        searchcmdlen;                /* length of previous search cmd */
  313. EXTERN int         reg_ic INIT(= 0);             /* p_ic passed to vim_regexec() */
  314. EXTERN int        reg_magic;                    /* p_magic passed to ergexec() */
  315.  
  316. EXTERN int        did_outofmem_msg INIT(= FALSE);
  317.                                             /* set after out of memory msg */
  318. EXTERN int        did_swapwrite_msg INIT(= FALSE);
  319.                                             /* set after swap write error msg */
  320. EXTERN int        undo_off INIT(= FALSE);        /* undo switched off for now */
  321. EXTERN int        global_busy INIT(= 0);        /* set when :global is executing */
  322. #ifdef SLEEP_IN_EMSG
  323. EXTERN int        dont_sleep INIT(= FALSE);    /* set when sleep() in emsg() not
  324.                                                 wanted */
  325. #endif
  326. EXTERN int        need_start_insertmode INIT(= FALSE);
  327.                                             /* start insert mode soon */
  328. EXTERN int        rc_did_emsg INIT(= FALSE);    /* vim_regcomp() called emsg() */
  329. EXTERN int        no_wait_return INIT(= 0);    /* don't wait for return now */
  330. EXTERN int        need_wait_return INIT(= 0);    /* need to wait for return later */
  331. EXTERN int        dont_wait_return INIT(= 0);    /* no need to wait for return */
  332. EXTERN int        quit_more INIT(= FALSE);    /* 'q' hit at "--more--" msg */
  333. EXTERN char_u    *last_cmdline INIT(= NULL);    /* last command line (for ":) */
  334. EXTERN char_u    *new_last_cmdline INIT(= NULL);    /* new value for last_cmdline */
  335. EXTERN char_u    *autocmd_fname INIT(= NULL); /* fname for "^Vf" on cmdline */
  336.  
  337. EXTERN int        postponed_split INIT(= FALSE);    /* for CTRL-W CTRL-] command */
  338. EXTERN int        replace_offset INIT(= 0);    /* offset for replace_push() */
  339.  
  340. EXTERN char_u    *escape_chars INIT(= (char_u *)" \t\\\"|");
  341.                                             /* need backslash in cmd line */
  342.  
  343. EXTERN char_u    *help_save_isk INIT(= NULL);/* 'isk' saved by do_help() */
  344. EXTERN long        help_save_ts INIT(= 0);        /* 'ts' saved by do_help() */
  345. EXTERN int        keep_help_flag INIT(= FALSE); /* doing :ta from help file */
  346.  
  347. /*
  348.  * When a string option is NULL (which only happens in out-of-memory
  349.  * situations), it is set to empty_option, to avoid having to check for NULL
  350.  * everywhere.
  351.  */
  352. EXTERN char_u    *empty_option INIT(= (char_u *)"");
  353.  
  354. #ifdef DEBUG
  355. EXTERN FILE *debugfp INIT(=NULL);
  356. #endif
  357.  
  358. #ifdef HAVE_LANGMAP
  359. EXTERN char_u    langmap_mapchar[256];    /* mapping for language keys */
  360. #endif
  361.  
  362. EXTERN char        breakat_flags[256];        /* which characters are in 'breakat' */
  363.  
  364. extern char *Version;            /* this is in version.c */
  365. extern char *longVersion;        /* this is in version.c */
  366.  
  367. /*
  368.  * Some file names for Unix are stored in pathdef.c, to make their value
  369.  * depend on the Makefile.
  370.  */
  371. #if defined(HAVE_CONFIG_H) || defined(OS2)
  372. extern char_u *sys_vimrc_fname;        /* this is in pathdef.c */
  373. extern char_u *sys_gvimrc_fname;    /* this is in pathdef.c */
  374. extern char_u *help_fname;            /* this is in pathdef.c */
  375. extern char_u *all_cflags;            /* this is in pathdef.c */
  376. #endif
  377.  
  378. EXTERN char_u no_lines_msg[]        INIT(="--No lines in buffer--");
  379.  
  380. /*
  381.  * The error messages that can be shared are included here.
  382.  * Excluded are very specific errors and debugging messages.
  383.  */
  384. EXTERN char_u e_abbr[]        INIT(="No such abbreviation");
  385. EXTERN char_u e_abort[]        INIT(="Command aborted");
  386. EXTERN char_u e_ambmap[]    INIT(="Ambiguous mapping");
  387. EXTERN char_u e_argreq[]    INIT(="Argument required");
  388. EXTERN char_u e_backslash[]    INIT(="\\ should be followed by /, ? or &");
  389. EXTERN char_u e_curdir[]    INIT(="Command not allowed from from .exrc/.vimrc in current dir");
  390. EXTERN char_u e_errorf[]    INIT(="No errorfile name");
  391. EXTERN char_u e_exists[]    INIT(="File exists (use ! to override)");
  392. EXTERN char_u e_failed[]     INIT(="Command failed");
  393. EXTERN char_u e_internal[]    INIT(="Internal error");
  394. EXTERN char_u e_interr[]    INIT(="Interrupted");
  395. EXTERN char_u e_invaddr[]    INIT(="Invalid address");
  396. EXTERN char_u e_invarg[]    INIT(="Invalid argument");
  397. EXTERN char_u e_invrange[]    INIT(="Invalid range");
  398. EXTERN char_u e_invcmd[]    INIT(="Invalid command");
  399. EXTERN char_u e_markinval[]    INIT(="Mark has invalid line number");
  400. EXTERN char_u e_marknotset[]    INIT(="Mark not set");
  401. EXTERN char_u e_nesting[]    INIT(="Scripts nested too deep");
  402. EXTERN char_u e_noalt[]        INIT(="No alternate file");
  403. EXTERN char_u e_nobang[]     INIT(="No ! allowed");
  404. EXTERN char_u e_nogvim[]    INIT(="GUI cannot be used: Not enabled at compile time\n");
  405. EXTERN char_u e_nohebrew[]    INIT(="Hebrew cannot be used: Not enabled at compile time\n");
  406. EXTERN char_u e_noinstext[]    INIT(="No inserted text yet");
  407. EXTERN char_u e_nolastcmd[]    INIT(="No previous command line");
  408. EXTERN char_u e_nomap[]        INIT(="No such mapping");
  409. EXTERN char_u e_nomatch[]    INIT(="No match");
  410. EXTERN char_u e_nomore[]    INIT(="No more files to edit");
  411. EXTERN char_u e_noname[]    INIT(="No file name");
  412. EXTERN char_u e_nopresub[]    INIT(="No previous substitute regular expression");
  413. EXTERN char_u e_noprev[]    INIT(="No previous command");
  414. EXTERN char_u e_noprevre[]    INIT(="No previous regular expression");
  415. EXTERN char_u e_norange[]     INIT(="No range allowed");
  416. EXTERN char_u e_noroom[]     INIT(="Not enough room");
  417. EXTERN char_u e_notcreate[]    INIT(="Can't create file %s");
  418. EXTERN char_u e_notmp[]        INIT(="Can't get temp file name");
  419. EXTERN char_u e_notopen[]    INIT(="Can't open file %s");
  420. EXTERN char_u e_notread[]    INIT(="Can't read file %s");
  421. EXTERN char_u e_nowrtmsg[]    INIT(="No write since last change (use ! to override)");
  422. EXTERN char_u e_null[]        INIT(="Null argument");
  423. EXTERN char_u e_number[]    INIT(="Number expected");
  424. EXTERN char_u e_openerrf[]    INIT(="Can't open errorfile %s");
  425. EXTERN char_u e_outofmem[]    INIT(="Out of memory!");
  426. EXTERN char_u e_patnotf[]    INIT(="Pattern not found");
  427. EXTERN char_u e_positive[]    INIT(="Argument must be positive");
  428. EXTERN char_u e_quickfix[]    INIT(="No Errors");
  429. EXTERN char_u e_re_damg[]    INIT(="Damaged match string");
  430. EXTERN char_u e_re_corr[]    INIT(="Corrupted regexp program");
  431. EXTERN char_u e_readonly[]    INIT(="'readonly' option is set (use ! to override)");
  432. EXTERN char_u e_readerrf[]    INIT(="Error while reading errorfile");
  433. EXTERN char_u e_scroll[]    INIT(="Invalid scroll size");
  434. EXTERN char_u e_toocompl[]    INIT(="Command too complex");
  435. EXTERN char_u e_toombra[]    INIT(="Too many (");
  436. EXTERN char_u e_toomket[]    INIT(="Too many )");
  437. EXTERN char_u e_toomsbra[]    INIT(="Too many [");
  438. EXTERN char_u e_toolong[]    INIT(="Command too long");
  439. EXTERN char_u e_toomany[]    INIT(="Too many file names");
  440. EXTERN char_u e_trailing[]    INIT(="Trailing characters");
  441. EXTERN char_u e_umark[]        INIT(="Unknown mark");
  442. EXTERN char_u e_unknown[]    INIT(="Unknown");
  443. EXTERN char_u e_write[]        INIT(="Error while writing");
  444. EXTERN char_u e_zerocount[]    INIT(="Zero count");
  445.